var ArchiveManager = {};

ArchiveManager.display = function(archiveId) {
    if(archiveId != null && archiveId.length > 0) {
        document.getElementById("mainFrame").src = PageContext.getContextPath() + "/note/archive/display.html?archiveId=" + archiveId;
    }
};

HTree.click = function(src) {
    var node = HTree.getNode(src);
    var userObject = HTree.getUserObject(src);

    if(userObject.type == "category") {
        HTree.setActive(node);

        /**
         * 不显示管理
         */
        if(userObject.categoryId == "0") {
            document.getElementById("mainFrame").src = PageContext.getContextPath() + "/note/category/list.html?categoryId=" + userObject.categoryId;
        }
        else {
            document.getElementById("mainFrame").src = PageContext.getContextPath() + "/note/archive/list.html?categoryId=" + userObject.categoryId;
        }
    }
    else if(userObject.type == "archive") {
        HTree.setActive(node);
        document.getElementById("mainFrame").src = PageContext.getContextPath() + "/note/archive/display.html?archiveId=" + userObject.archiveId;
    }
};

jQuery(function() {
    HTree.config.stylePath = PageContext.getContextPath() + "/resource/htree/note/";

    var url = PageContext.getContextPath() + "/note/category/getCategoryXml.html?categoryId=" + PageContext.getAttribute("categoryId");
    var tree = new HTree.TreeNode({text: PageContext.getAttribute("categoryName"), href: PageContext.getContextPath() + "/note/category/list.html", xmlSrc: url});

    tree.load(function() {
        this.render(document.getElementById("htree"));
    });
});

jQuery(function() {
    var archiveId = Footprint.getValue();

    if(archiveId != null) {
        ArchiveManager.display(archiveId);
    }
});

/**
 * 
 */
jQuery(function() {
    jQuery("div.fill-panel").hover(function() {
        this.style.overflow = "auto";
    }, function() {
        this.style.overflow = "hidden";
    });
});
